import { defineStore } from "pinia";
import { store } from "@/store";
import asyncRoutes from "@/router/permisson-routes";
import commonRoutes from "@/router/routes";
import { login } from "@/api/user";
import { storage } from "@/utils/storage";
import router from "@/router";

export const useAppStore = defineStore({
  id: "app",
  state: (): any => ({
    showMask: null,
    theme: {
      token: {
        colorPrimary: "#008dff",
      },
    },
  }),
  getters: {
    getTheme(): any {
      return this.theme;
    },
    getMask(): any {
      return this.showMask;
    },
  },
  actions: {
    setAppMask(opts) {
      this.showMask = opts;
    },
    changeTheme(opts) {
      this.theme.token = Object.assign(this.theme.token, opts);
    },
  },
  // 开启数据缓存
  persist: {
    enabled: false,
  },
});

// Need to be used outside the setup
export function useAppStoreWidthOut() {
  return useAppStore(store);
}
